#include <stdio.h>
#include <stdlib.h>

struct node
{
    int data;
    struct node* next;
};

typedef struct node node_t;

int node_init(node_t *rv)
{
	rv->data = 0;
	rv->next = NULL;
	if(rv == NULL) return 0;
	else return 1;
}

void node_push_end(node_t *rv, int data)
{
	node_t *temp;
	//temp = rv;
	temp = (node_t *)malloc(sizeof(node_t));

	temp->data = data;
	temp->next = NULL;

	node_t *current = rv;
	while(current != NULL)
	{
		if(current->next == NULL)
		{
			current->next = temp;
			return;
		}
		current = current->next;
	}
}

void print_list(node_t *rv)
{
	node_t *temp = rv;
	while(temp != NULL)
	{
		printf("data: %d\n", temp->data);
		temp = temp->next;
	}
}

void main(void)
{
	node_t newNode, *firstNode;
	firstNode = &newNode;
	node_init(&newNode);

	node_push_end(&newNode, 10);
	node_push_end(&newNode, 3);
	node_push_end(&newNode, 1);
	print_list(&newNode);
}

